package cn.bone.base.bean;

import lombok.Data;

import java.util.Map;

@Data
public class RequestInfo {

    public static ThreadLocal<RequestInfo> info = new ThreadLocal<>();

    private Long requestId;             //请求编号
    private String url;                 //请求url
    private String token;               //客户端token
    private String host;                //客户端ip
    private Map<String,String> headers; //请求头
    private Map<String,String> params;  //客户端请求参数
    private Integer code;               //返回状态码
    private Integer time;               //请求耗时
    private Long startTime;             //请求开始时间戳

    private RequestClientInfo clientInfo;
    private RequestDeviceInfo deviceInfo;


    @Data
    public static class RequestClientInfo{
        private String appKey;          //客户端key
        private String appSecret;       //客户端秘钥
        private String clientVersion;   //客户端版本
        private String origin;          //客户端来源
        private String random;          //随机数
    }

    @Data
    public static class RequestDeviceInfo{
        private String deviceId;        //设备号
        private String deviceBand;      //设备品牌
        private String deviceModel;     //设备型号
        private String deviceVersion;   //设备版本
        private String screen;          //屏幕尺寸
        private String netOperator;     //网络运营商
        private String netType;         //网络类型
    }

    public static RequestInfo get(){
        return info.get();
    }

    public static void set(RequestInfo value){
        info.set(value);
    }

    public static void remove(){
        info.remove();
    }
}
